﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EmoneyWeiXinEntity;
using EmoneyWeiXinCommon;
using System.Data.SqlClient;
using System.Data;
namespace EmoneyWeiXinDAL
{
    public class CustomAccountManagerDal
    {
       
        public static List<CustomAccountManagerEntity> getCustomAccountManagerList(int pindex, int psize, int weixinid, out int total)
        {
            SqlParameter[] parameters = new SqlParameter[] {
            new SqlParameter("@pindex",pindex),
            new SqlParameter("@psize", psize),
            new SqlParameter("@total",0),
            new SqlParameter("@weixinid",weixinid)
            };
            parameters[2].Direction = ParameterDirection.Output;
            List<CustomAccountManagerEntity> result = SQLHelper.GetProcedureDataByColumnsLst<CustomAccountManagerEntity>(Config.EmoneyWeiXin, "sp_CustomAccountManager_Select", parameters);
            total = Convert.ToInt32(parameters[2].Value);
            return result;
        }
        public static List<CustomAccountManagerEntity> getCustomAccountManagerListByID(int id)
        {
            SqlParameter[] parameters = new SqlParameter[] {
            new SqlParameter("@id",id)
            };
            List<CustomAccountManagerEntity> result = SQLHelper.GetProcedureDataByColumnsLst<CustomAccountManagerEntity>(Config.EmoneyWeiXin, "sp_CustomAccountManager_SelectByID", parameters);
            return result;
        }
        public static List<CustomAccountManagerEntity> getCustomAccountManagerList()
        {
            List<CustomAccountManagerEntity> result = SQLHelper.GetProcedureDataByColumnsLst<CustomAccountManagerEntity>(Config.EmoneyWeiXin, "sp_CustomAccountManager_Select2", null);
            return result;
        }
        public static int UpdateCustomAccountManager(CustomAccountManagerEntity obj)
        {
            SqlParameter[] parameters = new SqlParameter[] {
            new SqlParameter("@id" , obj.id),
            new SqlParameter("@account", obj.account),
            new SqlParameter("@pwd", obj.pwd),
            new SqlParameter("@createtime", obj.createtime),
            new SqlParameter("@isvalid", obj.isvalid),
            new SqlParameter("@creator", obj.creator),
            new SqlParameter("@updatetime", obj.updatetime),
            new SqlParameter("@weixinid" , obj.weixinid)
            };
            int result = SQLHelper.ExecuteNonQuery(Config.EmoneyWeiXin, CommandType.StoredProcedure, "sp_CustomAccountManager_Update", parameters);
            return result;
        }
        public static int DeleteCustomAccountManager(int id)
        {
            SqlParameter[] parameters = new SqlParameter[] {  
            new SqlParameter("@id", id)};
            int result = SQLHelper.ExecuteNonQuery(Config.EmoneyWeiXin, CommandType.StoredProcedure, "sp_CustomAccountManager_Delete", parameters);
            return result;
        }
    }
}
